//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing.Diagram
{
    static class ReaderHelper
    {
        public static IEnumerable<IOfficeXmlSerializable> ReadItems (ReadContext c)
        {
            while (c.ReaderLocalName != null)
                yield return readItem(c);
        }
        static IOfficeXmlSerializable readItem(ReadContext c)
        {
            switch (c.ReaderLocalName)
            {
                case "alg":
                    return c.ReadElement<Algorithm>();
                case "shape":
                    return c.ReadElement<Shape>();
                case "presOf":
                    return c.ReadElement<PresentationOf>();
                case "constrLst":
                    return c.ReadElement<Constraints>();
                case "ruleLst":
                    return c.ReadElement<Rules>();
                case "varLst":
                    return c.ReadElement<LayoutVariablePropertySet>();
                case "forEach":
                    return c.ReadElement<ForEach>();
                case "layoutNode":
                    return c.ReadElement<LayoutNode>();
                case "choose":
                    return c.ReadElement<Choose>();
                case "extLst":
                    return c.ReadElement<OfficeArtExtensionList>();

                default: throw new NotSupportedException();

            }

        }

    }
}